﻿using Cofe.Core.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cofe.Core.Filter
{
    public static class IFilterExtension
    {

        public static int GetPriority(this IFilter filter)
        {
            if (filter is IPropertyEntryFilter)
                return 0;
            return FilterAttribute.GetFilterAttribute(filter).Priority;
        }

        public static string GetSearchString(this IFilter filter)
        {
            return CofeServices.EntryFilterParser.FilterToFilterString(filter);
        }

        public static Guid GetId(this IFilter filter)
        {
            return StringUtils<IFilter>.
                 GetDeterministicGuid(filter.GetSearchString().ToLower());
        }

    }
}
